package com.zxr.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.zxr.common.annotation.Log;
import com.zxr.common.enums.BusinessType;
import com.zxr.system.domain.MemberProduct;
import com.zxr.system.service.IMemberProductService;
import com.zxr.common.core.controller.BaseController;
import com.zxr.common.core.domain.AjaxResult;
import com.zxr.common.utils.poi.ExcelUtil;
import com.zxr.common.core.page.TableDataInfo;

/**
 * 会员商品Controller
 * 
 * @author zxrproject
 * @date 2025-05-04
 */
@Controller
@RequestMapping("/system/memberProduct")
public class MemberProductController extends BaseController
{
    private String prefix = "system/memberProduct";

    @Autowired
    private IMemberProductService memberProductService;

    @RequiresPermissions("system:memberProduct:view")
    @GetMapping()
    public String product()
    {
        return prefix + "/product";
    }

    /**
     * 查询会员商品列表
     */
    @RequiresPermissions("system:memberProduct:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(MemberProduct memberProduct)
    {
        startPage();
        List<MemberProduct> list = memberProductService.selectMemberProductList(memberProduct);
        return getDataTable(list);
    }


    /**
     * 修改会员商品
     */
    @RequiresPermissions("system:memberProduct:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        MemberProduct memberProduct = memberProductService.selectMemberProductById(id);
        mmap.put("memberProduct", memberProduct);
        return prefix + "/edit";
    }

    /**
     * 修改保存会员商品
     */
    @RequiresPermissions("system:memberProduct:edit")
    @Log(title = "会员商品", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(MemberProduct memberProduct)
    {
        return toAjax(memberProductService.updateMemberProduct(memberProduct));
    }

}
